var mysex=0;
getimage=function(){
	let xml;
	if (window.XMLHttpRequest)
	{
	    //  IE7+, Firefox, Chrome, Opera, Safari 浏览器执行代码
	    xml=new XMLHttpRequest();
	}
	else
	{
	    // IE6, IE5 浏览器执行代码
	    xml=new ActiveXObject("Microsoft.XMLHTTP");
	}
	xml.onreadystatechange=function(){
		if(xml.readyState==4&&xml.status==200){
			if(xml.responseText!="null"&&xml.responseText!="")
			{
				 let t=JSON.parse(xml.responseText);
				 let img=document.getElementById('mytx');
				 let hometown=document.getElementById('hometown');
				 let in_name=document.getElementById('in_name');
				 hometown.value=t.data.rHome;
				 in_name.value=t.data.rName;
				 mysex=t.data.rSex;
				 if(mysex==1)
				 sexclick("man");
				 else
				 sexclick("women");
				 img.src=t.data.rImgurl;
			}

		}
	}
	xml.open("post","/roles/getRoles",true);
	xml.setRequestHeader('content-type','application/x-www-form-urlencoded');
	xml.send();
}
sexclick=function(val){
	let b1=document.getElementById("man");
	let b2=document.getElementById("women");
	//alert(val);
	if(val=="man"){
		b1.style.color="blue";
		mysex=1;
		b1.style.backgroundColor="cornflowerblue";
		b2.style.color="rgba(38,38,38,.75)";
        b2.style.backgroundColor="rgba(0,0,0,.03)";
	}else{
		b2.style.color="deeppink";
		mysex=2;
		b2.style.backgroundColor="pink";
		b1.style.color="rgba(38,38,38,.75)";
        b1.style.backgroundColor="rgba(0,0,0,.03)";
	}
}
inputclick=function(val){
	let t1=document.getElementById(val);
	t1.style.borderStyle="solid";
	t1.style.borderColor="#007aff";
}

clearinput=function(){
	let input_text=['hometown','in_name'];
	for(let i=0;i<2;i++){
		let t=document.getElementById(input_text[i]);
		t.style.outline="none";
		t.style.borderStyle="none";
	}
}
fileclick=function(){
	let t=document.getElementById("file");
	t.click();
}

function getValue()
{
	let x=document.getElementById("file").value;
	if(x=="")
	{
	return false;
	}
	return true;
}
window.onfocus = function () {
	setTimeout(() =>{
		document.getElementById("mysubmit").click();
	}, 1000);
};
save=function(){
	let username=document.getElementById("in_name").value;
	let imgurl=document.getElementById("mytx").src;
	let home=document.getElementById("hometown").value;
	let xml;
	if (window.XMLHttpRequest)
	{
	    xml=new XMLHttpRequest();
	}
	else
	{
	    // IE6, IE5 浏览器执行代码
	    xml=new ActiveXObject("Microsoft.XMLHTTP");
	}
	xml.onreadystatechange=function(){
		if(xml.readyState==4&&xml.status==200){
		}
	}
	xml.open("post","/roles/updateRoles",true);
	xml.setRequestHeader('content-type','application/x-www-form-urlencoded');
	xml.send('rName='+username+'&rImgurl='+imgurl+'&rHome='+home+'&rSex='+mysex);
}
